package com.rayboo.example.design.pattern.adapter.actual;

/**
 * 结果适配器
 *
 * @author ray
 */
public abstract class OnResultAdapter implements OnResponseListener, OnResultListener {

    @Override
    public void onResponse(String response) {
        String[] res = response.split(HttpManager.DIVIDER);
        String code = res[0];
        String result = res[1];
        if (HttpManager.CODE_SUCCESS.equals(code)) {
            onSuccess(result);
            return;
        }
        onFailed(code, result);
    }

    @Override
    public void onError(String code, String message) {
        onFailed(code, message);
    }

    @Override
    public void onFailed(String code, String message) {
        onError(code, message);
    }
}
